/*
 * @Author: your name
 * @Date: 2022-01-31 15:18:29
 * @LastEditTime: 2022-03-12 18:04:38
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \vue3-ts-food-admin\src\router\router.ts
 */
import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";
// import { getToken } from "@/utils/tool";
import { IMenubarList } from "@/types/index";

const routes: IMenubarList[] = [
  {
    path: "/",
    name: "foodadmin",
    redirect: "/workspace",
    meta: {
      hidden: true,
      title: "",
      icon: "",
    },
  },
  {
    path: "/workspace",
    name: "workspace",
    //  redirect: "/workspace/home",
    component: () => import("@/layout/layout.vue"),
    meta: { title: "主页", icon: "", activeMenu: "/workspace/home" },
    // children: workspaceRoutes,
  },
];

const router = createRouter({
  routes: routes as RouteRecordRaw[],
  history: createWebHashHistory(),
});

// router.beforeEach((to, from, next) => {
//   const token = getToken();

//   if (token) {
//     if (to.path === "/login") {
//       next("/");
//     } else {
//       next();
//     }
//   } else {
//     if (to.path !== "/login") {
//       next("/login");
//     } else {
//       next();
//     }
//   }
// });

export default router;
